package com.kk.base.controller.home;

import com.kk.base.bean.Result;
import com.kk.base.entity.admin.User;
import com.kk.base.service.admin.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @info : 前台地图搜索控制层
 */
@Controller
@RequestMapping("/home/map")
public class HomeMapController {

    @Autowired
    private UserService userService;


    /**
     * 跳转到个人中心首页
     * @return
     */
    @RequestMapping("/index")
    public String index(Model model){
        model.addAttribute("index",5);
    return "home/map";
    }


    /**
     * 根据省市区查询
     * @param address
     * @return
     */
    @RequestMapping("/query")
    @ResponseBody
    public Result<List<User>> query(@RequestParam("address") String address){
        List<User> userList = userService.findByUserTypeAndAddress(address);
        return Result.success(userList);
    }


}
